<template>
  <div class="app">
    <h2>我是App组件</h2>
    <h3>Child给我一台电脑:{{ dn }}</h3>
    <br>
    <Child ref="haizi"/>
    <Child></Child>
  </div>
</template>

<script>
import Child from "./components/Child";

export default {
  name: 'App',
  components: {Child},
  data() {
    return {
      dn: ""
    }
  },
  methods: {
    demo(c) {
      console.log(this.$refs.haizi)
      this.dn=c
    }
  },
mounted(){
    this.$refs.haizi.$on('fangjiale',this.demo)
  }
}
</script>

<style>
.app {
  background: hotpink;
  padding: 10px;
}
</style>